/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author teo
 */
@Entity
@Table(name = "CHECKS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Checks.findAll", query = "SELECT c FROM Checks c"),
    @NamedQuery(name = "Checks.findByCheckId", query = "SELECT c FROM Checks c WHERE c.checkId = :checkId"),
    @NamedQuery(name = "Checks.findByCode", query = "SELECT c FROM Checks c WHERE c.code = :code"),
    @NamedQuery(name = "Checks.findByDatetime", query = "SELECT c FROM Checks c WHERE c.datetime = :datetime"),
    @NamedQuery(name = "Checks.findByValid", query = "SELECT c FROM Checks c WHERE c.valid = :valid")})
public class Checks implements Serializable {
    @Column(name = "DATETIME")
    private String datetime;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CHECK_ID")
    private Integer checkId;
    @Basic(optional = false)
    @Column(name = "CODE")
    private int code;
    @Basic(optional = false)
    @Column(name = "VALID")
    private String valid;
    @JoinColumn(name = "OWNER", referencedColumnName = "CUSTOMER_ID")
    @ManyToOne(optional = false)
    private Customer owner;

    public Checks() {
    }

    public Checks(Integer checkId) {
        this.checkId = checkId;
    }

    public Checks(Integer checkId, int code, Date datetime, String valid) {
        this.checkId = checkId;
        this.code = code;
        this.datetime = datetime.toString();
        this.valid = valid;
    }

    public Integer getCheckId() {
        return checkId;
    }

    public void setCheckId(Integer checkId) {
        this.checkId = checkId;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValid() {
        return valid;
    }

    public void setValid(String valid) {
        this.valid = valid;
    }

    public Customer getOwner() {
        return owner;
    }

    public void setOwner(Customer owner) {
        this.owner = owner;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (checkId != null ? checkId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Checks)) {
            return false;
        }
        Checks other = (Checks) object;
        if ((this.checkId == null && other.checkId != null) || (this.checkId != null && !this.checkId.equals(other.checkId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Checks[ checkId=" + checkId + " ]";
    }

    public String getDatetime() {
        return datetime;
    }

    public void setDatetime(String datetime) {
        this.datetime = datetime;
    }
    
}
